package com.leetcode.partition14;

/**
 * @author rkc
 * @date 2022/8/23 9:02
 */
public class LC1329将矩阵按对角线排序 {

    public int[][] diagonalSort(int[][] mat) {
        int n = mat.length, m = mat[0].length;
        for (int k = 0; k < Math.min(n, m); k++) {
            for (int i = 0; i < n - 1; i++) {
                for (int j = 0; j < m - 1; j++) {
                    if (mat[i][j] > mat[i + 1][j + 1]) {
                        int t = mat[i][j];
                        mat[i][j] = mat[i + 1][j + 1];
                        mat[i + 1][j + 1] = t;
                    }
                }
            }
        }
        return mat;
    }
}
